package structure;
import java.util.*;

public class Test5 {
    //蓝桥杯 左移右移(⭐⭐⭐)
    public static void main0(String[] args) {
        Scanner in = new Scanner(System.in);
        //在此输入您的代码...
        int N = in.nextInt();
        int M = in.nextInt();
        int[] arr = new int[N + 5];
        int[] next = new int[N + 5];
        int[] prev = new int[N + 5];
        for(int i = 1;i <= N;i++){
            arr[i] = i;
            next[i] = i + 1;
            prev[i] = i - 1;
        }
        next[0] = 1;
        prev[N + 1] = N;
        while(M-- > 0){
            char c = in.next().charAt(0);
            int num = in.nextInt();
            //删除元素
            next[prev[num]] = next[num];
            prev[next[num]] = prev[num];
            if(c == 'L'){
                prev[next[0]] = num;
                prev[num] = 0;
                next[num] = next[0];
                next[0] = num;
            }else {
                next[prev[N + 1]] = num;
                prev[num] = prev[N + 1];
                next[num] = N + 1;
                prev[N + 1] = num;
            }
        }
        for(int i = next[0];i != N + 1;i = next[i]){
            System.out.print(i + " ");
        }
        in.close();
    }
    //蓝桥杯 书架排列(⭐⭐⭐)
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        //在此输入您的代码...
        int n = in.nextInt();
        int m = in.nextInt();
        int[] next = new int[n + 5];
        int[] prev = new int[n + 5];
        for(int i = 1;i <= n;i++){
            next[i] = i + 1;
            prev[i] = i - 1;
        }
        next[0] = 1;
        prev[n + 1] = n;
        while(m-- > 0){
            int num = in.nextInt();
            if(num == 1){
                int node = in.nextInt();
                next[prev[node]] = next[node];
                prev[next[node]] = prev[node];

                prev[next[0]] = node;
                next[node] = next[0];
                prev[node] = 0;
                next[0] = node;
            }else if(num == 2){
                int node = in.nextInt();
                next[prev[node]] = next[node];
                prev[next[node]] = prev[node];

                next[prev[n + 1]] = node;
                prev[node] = prev[n + 1];
                next[node] = n + 1;
                prev[n + 1] = node;
            }else {
                int node = in.nextInt();
                int cur = in.nextInt();
                if(node == cur)continue;
                next[prev[node]] = next[node];
                prev[next[node]] = prev[node];

                prev[next[cur]] = node;
                next[node] = next[cur];
                prev[node] = cur;
                next[cur] = node;
            }
        }
        for(int i = next[0];i != n + 1;i = next[i]){
            System.out.print(i + " ");
        }
        in.close();
    }
}
